import $ax from './_axios'
import axios from 'axios'
// 获取药品类型
export function getTypeList(data) {
    return axios.get('/appUrl/system/dict/data/dictType/drug_type')
        .then(function(response) {
            // console.log(response);
            return response.data
        })
        .catch(function(error) {
            console.log(error);
        });
}
// 获取药品列表
export function getMedList(data) {
    // , { pageNum: data.page, pageSize: data.pageSize, drugType: data.drugType }
    return $ax.get(`/appUrl/drugs/list?pageNum=${data.page}&pageSize=${data.pageSize}&drugType=${data.drugType}`).then(res => {
        return res.data
    })
}

// 获取购物车列表
export function getShopList(data) {
    return $ax.get(`/appUrl/shop/card/list?pageNum=${data.page}&pageSize=${data.pageSize}`).then(res => {
        return res.data
    })
}
// 购物车删除
export function deleteShop(data) {
    return $ax.post(`/appUrl/shop/card/deleteShopCard`, data).then(res => {
        return res.data
    })
}
// 获取订单列表
export function getOrderList(data) {
    return $ax.get(`/appUrl/order/list?pageNum=${data.page}&pageSize=${data.pageSize}&state=${data.state}`).then(res => {
        return res.data
    })
}
// 根据id获取物品详情
export function getShopById(data) {
    return $ax.get(`/appUrl/drugs/${data.id}`).then(res => {
        return res.data
    })
}
// 单个物品加入购物车
export function addShoppingCar(data) {
    return $ax.post(`/appUrl/shop/card/addShopCard`, data).then(res => {
        return res.data
    })
}
// 购物车生成订单
export function shopToOrder(data) {
    return $ax.post(`/appUrl/drugs/addOrder`, data).then(res => {
        return res.data
    })
}
// 订单确认收货
export function confirmReceipt(data) {
    return $ax.post(`/appUrl/order/updateOrderReceipt`, data).then(res => {
        return res.data
    })
}
export function getHomeProductList(data) {
    return $ax.get('/index/index', { params: data }).then(res => {
        return res.data
    })
}

export function getHomeProductDetail(data) {
    return $ax.get('/index/detail', { params: data }).then(res => {
        return res.data
    })
}

export function getShopProductList(data) {
    return $ax.get('/product/index', { params: data }).then(res => {
        return res.data
    })
}

export function getShopProductDetail(data) {
    return $ax.get('/product/detail', { params: data }).then(res => {
        return res.data
    })
}

export function getTreasureList(data) {
    return $ax.get('/prize/index', { params: data }).then(res => {
        return res.data
    })
}

export function getTreasureDetail(data) {
    return $ax.get('/prize/detail', { params: data }).then(res => {
        return res.data
    })
}

export function getTreasureHistory(data) {
    return $ax.get('/prize/history', { params: data }).then(res => {
        return res.data
    })
}

export function orderHomeProduct(data) {
    return $ax.post('/order/pre-buy', data).then(res => {
        return res.data
    })
}

export function orderShopProduct(data) {
    return $ax.post('/order/shop', data).then(res => {
        return res.data
    })
}

export function orderTreasure(data) {
    return $ax.post('/order/prize', data).then(res => {
        return res.data
    })
}